package com.zbkj.crmeb.merchant.admin.controller;

import com.common.CommonPage;
import com.common.PageParamRequest;
import com.crmeb.core.common.CommonResult;
import com.utils.vo.dateLimitUtilVo;
import com.zbkj.crmeb.store.response.RefundProductBoardResponse;
import com.zbkj.crmeb.store.service.TransactionAnalysisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("api/admin/mer/transaction/analysis")
@Api(tags = "交易分析")
public class MerTransactionAnalysisController extends AdminBaseController{

    @Autowired
    private TransactionAnalysisService transactionAnalysisService;

    /**
     * 功能描述: 获取店铺交易转化数据
     * @Param: [dateLimit, request]
     * @Return: com.crmeb.core.common.CommonResult<java.util.Map<java.lang.String,java.lang.Object>>
     * @Author: wangzh
     * @Date: 2023/1/3 14:32
     */
    @ApiOperation(value = "店铺交易转化")
    @GetMapping("/conversion")
    public CommonResult<Map<String, Object>> transactionConversion(dateLimitUtilVo dateLimit, HttpServletRequest request){
        return CommonResult.success(transactionAnalysisService.transactionConversion(dateLimit, getMerId(request)));
    }

    /**
     * 功能描述: 退款看板
     * @Param: [dateLimit, request]
     * @Return: com.crmeb.core.common.CommonResult<java.util.Map<java.lang.Object,java.lang.Object>>
     * @Author: wangzh
     * @Date: 2023/1/4 15:20
     */
    @ApiOperation(value = "退款看板")
    @GetMapping("/refundBoard")
    public CommonResult<Map<Object, Object>> refundBoard(dateLimitUtilVo dateLimit, HttpServletRequest request){
        return CommonResult.success(transactionAnalysisService.refundBoard(dateLimit, getMerId(request)));
    }

    /**
     * 功能描述: 退款商品信息
     * @Param: [request, servletRequest]
     * @Return: com.crmeb.core.common.CommonResult<com.common.CommonPage<com.zbkj.crmeb.store.response.RefundProductBoardResponse>>
     * @Author: wangzh
     * @Date: 2023/1/4 15:20
     */
    @ApiOperation(value = "退款商品")
    @GetMapping("/refundProduct")
    public CommonResult<CommonPage<RefundProductBoardResponse>> refundProduct(PageParamRequest request, HttpServletRequest servletRequest){
        return CommonResult.success(CommonPage.restPage(transactionAnalysisService.refundProduct(request, getMerId(servletRequest))));
    }
}
